package com.example.demo.nio;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

@Slf4j
public class NioClient {

    public static void main(String[] args) {
        try {
            SocketChannel sc = SocketChannel.open();
            sc.connect(new InetSocketAddress("localhost",8082));
            log.debug("-------连接等待中-------");
            sc.write(Charset.defaultCharset().encode("01230123456789abcdef"));
//            sc.write(Charset.defaultCharset().encode("0123456789abcdef\n"));
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
